
*=============================================================================

*** Setup

version 15
capture log close
set more off
clear all

*=============================================================================

*** US

* Individual level data
use "$data/us_prep_import.dta", clear
merge 1:1 caseid using "$data/us_ctb_formerge.dta", nogen
compress
save "$data/us_indlevel_touse", replace
clear

* Conjoint (scenario level) data
use "$data/us_scenariolevel", clear
merge m:1 caseid using "$data/us_ctb_formerge.dta", nogen
save "$data/us_scenlevel_touse", replace
clear

* Alternative conjoint (scenario level) data
use "$data/us_scenariolevel_doubletiming", clear
merge m:1 caseid using "$data/us_ctb_formerge.dta", nogen
save "$data/us_scenlevel_doubletiming_touse", replace
clear

*=============================================================================

*** UK

* Individual level data
use "$data/uk_prep_import.dta", clear
merge 1:1 caseid using "$data/uk_ctb_formerge.dta", nogen
compress
save "$data/uk_indlevel_touse", replace
clear

* Conjoint (scenario level) data
use "$data/uk_scenariolevel", clear
merge m:1 caseid using "$data/uk_ctb_formerge.dta", nogen
save "$data/uk_scenlevel_touse", replace
clear

*=============================================================================

*** Germany

* Individual level data
use "$data/de_prep_import.dta", clear
merge 1:1 caseid using "$data/de_ctb_formerge.dta", nogen
compress
save "$data/de_indlevel_touse", replace
clear

* Conjoint (scenario level) data
use "$data/de_scenariolevel", clear
merge m:1 caseid using "$data/de_ctb_formerge.dta", nogen
save "$data/de_scenlevel_touse", replace
clear

*=============================================================================

*** France

* Individual level data
use "$data/fr_prep_import.dta", clear
merge 1:1 caseid using "$data/fr_ctb_formerge.dta", nogen
compress
save "$data/fr_indlevel_touse", replace
clear

* Conjoint (scenario level) data
use "$data/fr_scenariolevel", clear
merge m:1 caseid using "$data/fr_ctb_formerge.dta", nogen
save "$data/fr_scenlevel_touse", replace
clear

*=============================================================================

*** Individual-level pooled data

* Load US and append other countries
use "$data/us_indlevel_touse.dta"

* gen country identifier
gen country=1
label var country "Country (1=US, 2=UK, 3=GE, 4=FR)"
append using "$data/uk_indlevel_touse.dta"
replace country=2 if country==.

append using "$data/de_indlevel_touse.dta"
replace country=3 if country==.

append using "$data/fr_indlevel_touse.dta"
replace country=4 if country==.

* Generate value label and country indicators
lab define country_lab 1 "United States" 2 "United Kingdom" 3 "Germany" 4 "France"
lab values country country_lab

tab country, gen(ctry_)
rename ctry_1 ctry_us
rename ctry_2 ctry_uk
rename ctry_3 ctry_de
rename ctry_4 ctry_fr

* Saving
compress
save "$data/pooled_touse.dta", replace
clear

*=============================================================================

*** Scenario-level pooled data

* Load US and append other countries
use "$data/us_scenlevel_touse.dta", clear

* gen country identifier
gen country=1
label var country "Country (1=US, 2=UK, 3=GE, 4=FR)"
append using "$data/uk_scenlevel_touse.dta"
replace country=2 if country==.

append using "$data/de_scenlevel_touse.dta"
replace country=3 if country==.

append using "$data/fr_scenlevel_touse.dta"
replace country=4 if country==.

* Generate value label and country indicators
lab define country_lab 1 "United States" 2 "United Kingdom" 3 "Germany" 4 "France"
lab values country country_lab

tab country, gen(ctry_)
rename ctry_1 ctry_us
rename ctry_2 ctry_uk
rename ctry_3 ctry_ge
rename ctry_4 ctry_fr

* Saving
compress
save "$data/pooled_scenlevel_touse.dta", replace
clear
